package com.cysion.study.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.cysion.study.R
import com.cysion.study.entity.AllResearchStuEntity
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import com.cysion.study.ktbox.base.ITEM_CLICK
import kotlinx.android.synthetic.main.item_class_manages.view.*

/**
 * Created by chu on 2019-06-30.
 */
class ClassManagesAdapter(mEntities: MutableList<AllResearchStuEntity>, mContext: Context) :
    BaseAdapter<AllResearchStuEntity>(mEntities, mContext) {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<AllResearchStuEntity> {
        return SourceHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_class_manages, parent, false)
        )
    }

    companion object {
        const val look = 101
        const val know = 102
        const val comment = 103

    }

    class SourceHolder(itemView: View) : BaseViewHolder<AllResearchStuEntity>(itemView) {
        override fun fillData(obj: AllResearchStuEntity, position: Int) {
            obj?.apply {
                itemView.tv_title.text=obj.name
                itemView.tv_time.text="下节课上课时间："+obj.startTime+"--"+obj.endTime
                itemView.tv_date.text=obj.currentNumber+"/"+obj.totalNumber
                itemView.setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, ITEM_CLICK)
                }
            }
        }
    }
}